package com.agriculture.monitor.base;

import com.agriculture.monitor.entity.User;

public class TContext {

    private static final ThreadLocal<User> LOCAL = new ThreadLocal();

    public static void set(User user) {
        LOCAL.set(user);
    }

    public static Integer getUserId() {
        if (null != LOCAL.get()) {
            return LOCAL.get().getId();
        }
        return null;
    }

    public static User getUser() {
        if (null != LOCAL.get()) {
            return LOCAL.get();
        }
        return null;
    }
}
